#include "includes.h"

extern uint16 amp[4];

extern int amp_time;

int is_intrack(int intrack){
  
switch(intrack){
        case 1:
            if(amp[0]>=AMP_IN_TRACK_LOW&&amp[1]>=AMP_IN_TRACK_LOW)
                return 1;
            else 
                return 0; /* locked */
            break;
        case 0:
            if(amp[0]>=AMP_IN_TRACK_LOW_STRICT&&amp[1]>=AMP_IN_TRACK_LOW_STRICT)
                return 1; /* unlocked */    
        else        
                return 0;
            break;
    }  
    return 0;
}

int is_instraight(void){
    if(amp[0]>=AMP_IN_STRAIGHT&&amp[1]>=AMP_IN_STRAIGHT)
        return 1;
    return 0;
}

int is_lost(int islost){
    if(!islost&&(amp[0]<=AMP_LOST&&amp[1]<=AMP_LOST))
        return 1; /* is lost */
    if(islost&&amp[0]>=AMP_BACK&&amp[1]>=AMP_BACK&&amp[2]>=AMP_M_BACK&&amp[3]>=AMP_M_BACK)
        return 0; /* is back */
    return islost; /* keep status as it is */
}